//
//  IVCSSDK.h
//  ivcs_ios_demo
//
//  Created by zealcomm user on 2020/10/21.
//  Copyright © 2020 zealcomm user. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "MediaStreamSettingOptions.h"
#import "CCSClient.h"
#import "IRTCSDK.h"

@protocol IVCSSDKDelegate <NSObject>
@optional
/// 房间有流需要渲染，已存在的流/新增的流
/// @param label 流标签
/// @param stream 流对象
-(void)onStreamAddWithLabel:(NSString *_Nullable)label andStream:(IRTCRemoteStream *_Nullable)stream;

/// 房间的流结束
/// @param label 流标签
/// @param stream 流对象
-(void)onStreamRemoveWithLabel:(NSString *_Nullable)label andStream:(IRTCRemoteStream *_Nullable)stream;

@end


NS_ASSUME_NONNULL_BEGIN
@interface IVCSSDK : NSObject

@property (nonatomic,weak) id<IVCSSDKDelegate>delegate;

/// ccs socketIo client
@property(strong,nonatomic)CCSClient *ccsClient;

/// irtc sdk
@property(strong,nonatomic)IRTCSDK *irtcSDK;

/// 实例化
+ (instancetype)shareSDK;

/// 访客初始化
/// @param serviceUrl 账号系统的后台地址
/// @param name 访客登录用户名
/// @param password 访客登录密码
/// @param org 访客所属机构名
/// @param mediaOptions 访客视频流的设置
/// @param onSuccess 初始化成功，返回用户基本信息
/// @param onFailure 初始化失败，返回错误信息
-(void)initWithServiceUrl:(NSString *)serviceUrl
        name:(NSString *)name
        password:(NSString *)password
        org:(NSString *)org
        mediaOptions:(MediaStreamSettingOptions *__nullable)mediaOptions
        onSuccess:(void (^)(NSDictionary *result))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;


/// 发起视频呼叫
/// @param requestParameter 呼叫参数
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)requestSession:(nonnull NSDictionary *)requestParameter
       onSuccess:(void (^)(NSDictionary *result))onSuccess
       onFailure:(void (^)(NSError *error))onFailure;



/// 退出会话
/// @param parameter 默认为空
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)quitSession:(_Nullable id)parameter
                onSuccess:(void (^)(void))onSuccess
                onFailure:(void (^)(NSError *error))onFailure;



/// 音视频加入会话
/// @param label 本端流标签
/// @param onSuccess 成功，返回本端流
/// @param onFailure 失败
-(void)startVideoWithLabel:(nonnull NSString *)label
                   onSuccess:(void (^)(IRTCLocalStream *localStream))onSuccess
                   onFailure:(void (^)(NSError *error))onFailure;




/// 渲染远端流
/// @param label 流标签
/// @param stream 远端流对象
/// @param view 渲染的控件
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)renderStreamWithLabel:(nonnull NSString *)label
                   remoteStream:(IRTCRemoteStream *)stream
                   renderView:(RTCEAGLVideoView *)view
                   onSuccess:(void (^)(void))onSuccess
                   onFailure:(void (^)(NSError *error))onFailure;


/// 切换摄像头
/// @param position 指定切换的方向
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)switchCameraDevicePosition:(AVCaptureDevicePosition)position
                        onSuccess:(void (^)(void))onSuccess
                        onFailure:(void (^)(NSError *error))onFailure;

/// 停止本地视频的声音/视频画面推送
/// @param type audio/video
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)muteWithMediaType:(IRTCTrackKind)type
            onSuccess:(void (^)(void))onSuccess
            onFailure:(void (^)(NSError *error))onFailure;


/// 恢复本地视频的声音/视频画面推送
/// @param type audio/video
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)unmuteWithMediaType:(IRTCTrackKind)type
            onSuccess:(void (^)(void))onSuccess
            onFailure:(void (^)(NSError *error))onFailure;

/// 分享url资源文件给对方
/// @param type 资源类型 ['doc','pic','video','aduio','page','paper']
/// @param url 资源地址
/// @param name 资源名字
/// @param roles 发送给角色 agents/customers
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)shareResourceWithType:(NSString *)type
                 resourceUrl:(NSString *)url
                 resourceName:(NSString *)name
                 toRoles:(NSString *)roles
                 onSuccess:(void (^)(void))onSuccess
                 onFailure:(void (^)(NSError *error))onFailure;


/// 分享资源文件
/// @param type 文件类型  ['doc','pic','video','aduio','page','paper']
/// @param uploadUrl 上传的url
/// @param fileData fileData
/// @param fileName 文件名
/// @param mimeType 文件类型
/// @param roles 发送给对方的角色 默认是agents
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)shareResourceWithType:(NSString *)type
            uploadUrl:(NSString *)uploadUrl
            fileData:(NSData *)fileData
            fileName:(NSString *)fileName
            mimeType:(NSString *)mimeType
            toRoles:(NSString *)roles
            onSuccess:(void (^)(void))onSuccess
            onFailure:(void (^)(NSError *error))onFailure;


/// 发送自定义消息
/// @param data 消息内容
/// @param roles 发送给角色 agents/customers
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendCustomMessage:(NSString *)data
        toRoles:(NSString *)roles
        onSuccess:(void (^)(void))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;


/// 发送文本消息
/// @param data 消息内容
/// @param roles 发送给角色 agents/customers
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendTextMessage:(NSString *)data
        toRoles:(NSString *)roles
        onSuccess:(void (^)(void))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;


/// 发送消息确认
/// @param data 消息确认的信息体
/// @param roles 发送给的角色 默认是“agents”
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendMessageConfirmation:(id)data
        toRoles:(NSString *)roles
        onSuccess:(void (^)(void))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;


/// 发送表单消息
/// @param data 消息内容
/// @param roles 发送给角色 agents/customers
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendFormData:(NSDictionary *)data
        toRoles:(NSString *)roles
        onSuccess:(void (^)(void))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;


/// 坐席发送用户信息，用户确认
/// @param sessionId sessionId
/// @param url 确认信息的url地址
/// @param userInfo 用户信息
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sureUserInfoWithSessionId:(NSString *)sessionId
        url:(NSString *)url
        userInfo:(NSMutableDictionary *)userInfo
        onSuccess:(void (^)(void))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;


/// 上传表单数据
/// @param sessionId 会话id
/// @param url 上传url
/// @param parameter 参数
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)uploadFormDataWithSessionId:(NSString *)sessionId
                        url:(NSString *)url
                        parameter:(NSMutableDictionary *)parameter
                        onSuccess:(void (^)(id))onSuccess
                        onFailure:(void (^)(NSError *error))onFailure;

/// 告知对方，本地音视频已准备完成
/// @param user 业务层面当前用户信息
/// @param roles 发送给的角色 默认是'agents'
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)readyToTalk:(NSDictionary *)user
            toRoles:(NSString *)roles
            onSuccess:(void (^)(void))onSuccess
            onFailure:(void (^)(NSError *error))onFailure;

@end

NS_ASSUME_NONNULL_END
